<template>
  <div>
    <Tutorial />
  </div>
</template>
<script>
import Cookies from 'js-cookie'
export default {
  name: 'IndexPage',

  // fetch 用法
  async fetch(context) {
    const { store, $api } = context
    if (store.state.user.token) {
      await $api.getUserInfo().then(({ code, data }) => {
        if (code === 200) {
          console.log(data)
          store.commit("user/SET_USERINFO", data)
          Cookies.set("userInfo", JSON.stringify(data))
        }
      })
    } else {
      store.commit("user/SET_USERINFO", {})
      Cookies.remove("userInfo")
    }

  }
}
</script>
